package com.pub;

public class Page {
	private int pageSize = 20;
	private int pageCount = 10;
	private int pageNo = 1;
	private String val = "";
public  Page(){
	this.setPageCount(10);
	this.setPageNo(1);
	this.setPageSize(20);
	this.setVal("");
};
public Page(String val){
	this.setPageCount(10);
	this.setPageNo(1);
	this.setPageSize(20);
	this.setVal(val);
};
	// val参数设置格式
	// val=","\val1\":\"value1\",\val2\":\"value2\""
	public synchronized void setVal(String val) {
		this.val = val;
	}

	public synchronized String getVal() {
		return val;
	}

	public synchronized int getPageSize() {
		return pageSize;
	}

	public synchronized void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public synchronized int getPageCount() {
		return pageCount;
	}

	public synchronized void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public synchronized int getPageNo() {
		return pageNo;
	}

	public synchronized void setPageNo(int pageNo) {

		this.pageNo = pageNo;

	}

	public synchronized void setPageNox(String pageNox) {
		if (pageNox == null) {
			this.pageNo = 1;

		} else {
			this.pageNo = Integer.parseInt(pageNox);
		}
	}

	public synchronized String getPageInfo() {
		String str = "<div id=\"pagerx\" style=\"margin-top:0px;text-align:right\"></div>\n";
		str = str
				+ "<script type=\"text/javascript\" language=\"javascript\">\n";
		str = str + "$(document).ready(function() {	\n";
		str = str + "$(\"#pagerx\").pager({ pagenumber: " + this.getPageNo()
				+ ", pagecount: " + this.getPageCount()
				+ ", buttonClickCallback: PageClick });\n";
		str = str + "});\n";
		str = str + "PageClick = function(pageclickednumber) {\n";
		str = str
				+ "$(\"#pagerx\").pager({ pagenumber: pageclickednumber, pagecount: "
				+ this.getPageCount()
				+ ", buttonClickCallback: PageClick });\n";
		str = str
				+ "$(\"#AjaxList\").load(window.location.pathname+\"?r=\"+Math.random(), {\"pageNo\":pageclickednumber,\"Ajax\":\"Ajax\""
				+ this.getVal() + "});\n";
		str = str + "}\n";
		str = str + "</script>\n";
		str = str + "\n";
		return str;
	}
}
